<template>
  <div class="rent_main">
    <div class="text_content">
      <textarea @keyup="writeContent" @input="writeContent" name="" id="" :placeholder="holder" cols="30" rows="10" v-model="value"
                maxlength="150" @change="passValue"></textarea>
      <div class="count">
        {{currentCount}}/{{totalCount-currentCount}}
      </div>
    </div>
  </div>
</template>
<style lang="scss">
  @import "../../common/sass/base.scss";
  .mint-indicator-mask {
    top: 0;
    left: 0;
    position: fixed;
    width: 100%;
    height: 100%;
    opacity: 0.5;
    background: #000;
    z-index: 667;
  }
  .rent_main {
    width: 100%;
    background-color: #fff;
    .text_content {
      padding: 10px;
      position: relative;
      .mint-cell:first-child .mint-cell-wrapper {
        background-color: #f2f2f2;
        border-radius: 6px;
        .mint-field-core {
          resize: none;
          background-color: #f2f2f2;
          font-size: 14px;
        }
      }
      textarea {
        box-sizing: border-box;
        width: 100%;
        padding: 10px;
        height: 120px;
        background: #f2f2f2;
        border-radius: 5px;
        resize: none;
        outline: none;
        border: none;
        font-size: 14px;
      }
      .count {
        position: absolute;
        bottom: 20px;
        right: 20px;
        color: #0078de;
      }
    }
  }
</style>
<script>
  import { Toast } from 'mint-ui'
  export default {
    data () {
      return {
        value: '',
        ready: false,
        isIOS: false,
        totalCount: 150,
        currentCount: 0
      }
    },
    props: ['holder'],
    created () {
    },
    methods: {
      writeContent() {
        this.currentCount = this.value.length
        let remainCount = this.totalCount - this.currentCount
        if (!remainCount) {
          Toast({
            message: '字数不能超过150',
            position: 'middle',
            duration: 1000
          })
        }
      },
      passValue() {
        this.$emit('getValue', this.value)
      }
    }
  }
</script>
